$(function(){ 
})
function addressdemo(address,province){
	$.getJSON("http://passer-by.com/data_location/list.json",function(data){ 
		var provinceid;
		for (var key in data){
			if(data[key]==address&&address!=""){
				$("#"+province+"").append('<option value='+key/10e4+' >'+data[key]+'</option>')
				provinceid=parseInt(key/10000);
			}else if(address==""){
				if(key%10e4==0){
				$("#"+province+"").append('<option value='+key/10e4+' )>'+data[key]+'</option>')
				}
			}
			
		}
		if(address==""){
			provincejs('11');
		}else{
			provincejs(provinceid);
		}
	})
}
/**
 * 省份
 * @param address
 * @returns
 */
function  provincejs(provinceid){
	$("#area").html("")
	$.getJSON("http://passer-by.com/data_location/list.json",function(data){ 
		var townidall=[];
		for (var key in data)
		{
		 if(key%10e3!=0&&parseInt(key/10e3)==provinceid){
			 townidall.push(key)
			 $("#area").append('<option value='+key+' >'+data[key]+'</option>')
		 }
		}
		town(townidall[0])
	})
	$("#area").on("change",function(){
		town($("option:selected",this).val())
	})
}
function town(townid){
	 $("#town").html("")
		$.getJSON("http://passer-by.com/data_location/town/"+townid+".json",function(data){ 
			for (var key in data)
			{
				 $("#town").append('<option >'+data[key]+'</option>')
			}
		})
}